<?php

namespace application\admin\controller;

class total extends base {

    /**
     * 会员统计
     */
    public function member_count() {
        $member = db('member');

        $month_where = strtotime('-1 month') . ' AND ' . time(); //最近30天
        $week_where = strtotime('-1 week') . ' AND ' . time(); //最近7天

        $yesterday_where = strtotime(date("Y-m-d", strtotime("-1 day"))) . ' AND ' . strtotime(date("Y-m-d")); //昨天0点到昨天24点
        $today_where = strtotime(date("Y-m-d")) . ' AND ' . time(); //今天0点到现在时间

        $member_total['total'] = $member->total();
        $member_total['month_total'] = $member->where("regdate BETWEEN $month_where")->total();
        $member_total['week_total'] = $member->where("regdate BETWEEN $week_where")->total();
        $member_total['yesterday_total'] = $member->where("regdate BETWEEN $yesterday_where")->total();
        $member_total['today_total'] = $member->where("regdate BETWEEN $today_where")->total();

        //debug($member_total);
        return $member_total;
    }

    /**
     * 内容统计
     */
    public function content_count() {
        $content = db('content');
        $month_where = strtotime('-1 month') . ' AND ' . time(); //最近30天
        $week_where = strtotime('-1 week') . ' AND ' . time(); //最近7天

        $yesterday_where = strtotime(date("Y-m-d", strtotime("-1 day"))) . ' AND ' . strtotime(date("Y-m-d")); //昨天0点到昨天24点
        $today_where = strtotime(date("Y-m-d")) . ' AND ' . time(); //今天0点到现在时间

        $content_total['total'] = $content->total();
        $content_total['month_total'] = $content->where("inputtime BETWEEN $month_where")->total();
        $content_total['week_total'] = $content->where("inputtime BETWEEN $week_where")->total();
        $content_total['yesterday_total'] = $content->where("inputtime BETWEEN $yesterday_where")->total();
        $content_total['today_total'] = $content->where("inputtime BETWEEN $today_where")->total();

        //debug($member_total);
        return $content_total;
    }

}
